package main

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/pkg/errors"
)

func main()  {
	err:=queryData()
	if err !=nil{
		fmt.Printf("error msg:%T %v\n",errors.Cause(err),errors.Cause(err))
	}
	
}


func queryData() error{
	db, err := sql.Open("mysql", "root:user@/test")
	defer db.Close()
	if err != nil{
		panic(err)
	}
	var uid int
	var username, department, created string
	err = db.QueryRow("select * from userinfo").Scan(&uid, &username, &department, &created)

	if err != sql.ErrNoRows{
		return errors.Wrap(err,"No data")
	}
	return nil
}
